/*
 * Poliz.h
 *
 *  Created on: 15.04.2012
 *      Author: Eugene Kornykhin
 */

#ifndef POLIZ_H_
#define POLIZ_H_

#include <vector>
#include <map>
#include <string>
#include <set>


class PElement;
class PolizIterator;
class PolizPosition;
using std::string;

class Poliz {
public:
	Poliz();
	Poliz(const Poliz &);
	virtual ~Poliz();

	Poliz &operator=(const Poliz &);

	void append(const PElement &);
	void saveLink(string name, PolizPosition place);
	void saveProcedure(string name, PolizPosition begin);

	PolizIterator begin();
	PolizIterator begin() const;
	PolizIterator end(); //get end() position to links table
	PolizIterator end() const; //get end() position to links table

	PolizPosition beginPosition() const;
	PolizPosition endPosition() const;


	typedef std::vector<const PElement*>::size_type index_type;

	bool hasLink(string name) const;
	bool hasProcedure(string name) const;
	PolizPosition getDestination(string link_or_proc) const;
	index_type numberOfElements() const;
	PElement &getElement(PolizPosition) const;
	std::set<string> getLinks() const;
	std::set<string> getProcedures() const;

private:
	std::vector<PElement*> elements;
	std::map<string, PolizPosition> links;
	std::map<string, PolizPosition> procedures;
};

#endif /* POLIZ_H_ */
